<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLessonsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('lessons', function(Blueprint $table){

            $table->increments('id')->comment('主键id');
            $table->string('name', 40)->comment('课程名称');
            $table->string('description', 255)->comment('课程简介');
			$table->text('outline')->nullable()->comment('课程纲要');
            $table->string('cover', 60)->default('lesson-image-default.jpg')->comment('课程封面图像的文件名');

            $table->unsignedInteger('teacher_id')->comment('教师id，外键');
            $table->foreign('teacher_id')->references('id')->on('users')->onDelete('cascade');

            $table->timestamps();
        });
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('lessons');
	}

}
